<template>
    <view>
        <u-navbar :placeholder="true" :fixed="true" :shadow="true" @leftClick="back" :autoBack="true" 
            :title="type==0?'保证金详情':'保函详情'" />

        <view class="uni-area">
            <uni-item-base class="u-m-t-30" :baseData="baseData" />
            <uni-item-base v-if="type==0" class="u-m-t-30" :baseData="bzjData" />
            <uni-item-base v-if="type==0" class="u-m-t-30" :baseData="bzjccData" />
            <uni-item-base v-if="type==1" class="u-m-t-30" :baseData="bhbxData" />
            <uni-accessory class="u-m-t-30 u-m-b-30" :accessorys="accessoryList"></uni-accessory>
        </view>
    </view>
</template>

<script>
export default {
    data(){
        return{
            id: null, 
            type: 0, // 默认为保证金详情
            baseData:{ // 基本信息
                line: false,
                title: '基本信息',
                list:[
                    { field:'xmmc', title:'项目名称', value:'' },
                    { field:'sghtzj', title:'施工合同造价', value:'', unit:'万元' },
                    { field:'sghtqx', title:'施工合同期限', value:'', unit:'天' },
                    { field:'xmszd', title:'项目所在地', value:'' }
                ]
            },
            bzjData:{ // 工资保证金专户信息
                line: false,
                title: '工资保证金专户信息',
                list:[
                    { field:'zhzh', title:'专户账号', value:'' },
                    { field:'zhmc', title:'账户名称', value:'' },
                    { field:'zhkhh', title:'专户开户行', value:'' },
                    { field:'zhye', title:'专户余额', value:'',unit:'元' },
                    { field:'zhzt', title:'账户状态', value:'' },
                    { field:'khrq', title:'开户日期', value:'' }
                ]
            },
            bzjccData:{ // 保证金储存信息
                line: false,
                title: '保证金储存信息',
                list:[
                    { field:'bxqnjsxmsghtzzj', title:'本辖区建筑项目施工合同总造价', value:'',unit:'元' },
                    { field:'zdzcqx', title:'自动转存期限', value:'',unit:'年' },
                    { field:'bzjjnje', title:'保证金缴纳金额', value:'',unit:'元' },
                    { field:'jnfs', title:'缴纳方式', value:'' },
                    { field:'bzjyjje', title:'保证金应储存金额', value:'',unit:'元' },
                    { field:'sfxsyhzc', title:'是否享受优惠政策', value:'' },
                    { field:'jmhje', title:'减免缓金额', value:'',unit:'元' },
                    { field:'jndw', title:'缴纳单位', value:'' },
                    { field:'jnyhmc', title:'缴纳银行名称', value:'' },
                    { field:'jnzh', title:'储存账号', value:'' },
                    { field:'jnsj', title:'储存时间', value:'' },
                    { field:'jbr', title:'经办人', value:'' },
                    { field:'jbrzjhm', title:'身份证号码', value:'' },
                    { field:'jbrlxdh', title:'联系方式', value:'', type:'phone' },
                    { field:'bz', title:'备注', value:'' },
                ]
            },
            bhbxData:{ // 保函/保险信息
                line: false,
                title: '保函/保险信息',
                list:[
                    { field:'lx', title:'担保类型', value:'' },
                    { field:'bxqnjsxmsghtzzj', title:'本辖区建筑项目施工合同总价', value:'', unit:'万元' },
                    { field:'bzjyjje', title:'应储存保证金金额', value:'', unit:'元' },
                    { field:'xz', title:'保函/保险性质', value:'' },
                    { field:'bhbxbh', title:'保函/保险编号', value:'' },
                    { field:'klrq', title:'开立日期', value:'' },
                    { field:'dbbxdw', title:'担保/保险单位', value:'' },
                    { field:'dbbxje', title:'担保/保险金额', value:'',unit:'元' },
                    { field:'zdxe', title:'最大限额', value:'',unit:'元' },
                    { field:'yxqqsrq', title:'有效期起止日期', value:'' },
                    { field:'yxqzzrq', title:'有效期终止日期', value:'' },
                    { field:'jbr', title:'经办人', value:'' },
                    { field:'jbrzjhm', title:'身份证号码', value:'' },
                    { field:'jbrlxdh', title:'联系电话', value:'', type:'phone' },
                    { field:'bz', title:'备注', value:'' },
                ] 
            },
            accessoryList:[]
        }
    },

    onLoad(option){
        this.id = option.id
        this.type = option.type
        this.getDetail()
    },

    methods: {
        back(){
            uni.navigateBack()
        },

        // 获取详情
        getDetail(){
            let api 
            if( this.type == 0 ){
                api = JSON.parse(JSON.stringify(this.$apis.bzjDetail))
            }else{
                api = JSON.parse(JSON.stringify(this.$apis.bhbxDetail))
            }
            api.url+=this.id
            this.$request(this,api,{}).then(res=>{
                // console.log(this.type==0?'保证金':'保函',res)
                this.baseData.list.map((v,i)=>{
                    v.value = res[v.field]||res[v.field]==0?res[v.field]:'暂无数据源'
                })
                if( this.type == 0 ){
                    this.bzjData.list.map((v,i)=>{
                        v.value = res[v.field]||res[v.field]==0?res[v.field]:'暂无数据源'
                    })
                    this.bzjccData.list.map((v,i)=>{
                        v.value = res[v.field]||res[v.field]==0?res[v.field]:'暂无数据源'
                    })
                }else{
                    this.bhbxData.list.map((v,i)=>{
                        v.value = res[v.field]||res[v.field]==0?res[v.field]:'暂无数据源'
                    })
                }
                this.getFjList(res.ywlx,res.id)
            })
        },
        // 获取附件列表
        getFjList(ywlx,ywbh){
            this.$request(this,this.$apis.CommonFjList,{ywlx:ywlx,ywbh:ywbh}).then(res=>{
                // console.log('附件',res)
                this.accessoryList = res
            })
        }
    },
}
</script>

<style scoped lang="scss">

</style>